/*!
 * \file GapStateBase.h
 * \brief Base class for all states in state machine for
 * GAP protocol in Serving Gateway
 */

#ifndef SGW_GAP_STATE_BASE_H
#define SGW_GAP_STATE_BASE_H

#include "StateBase.h"
#include "GapEventConnectionInd.h"
#include "GapEventT823Expired.h"
#include "GapEventT8221Expired.h"
#include "GapEventEchoResp.h"
#include "GapEventMediaTransmissionFinishedInd.h"
#include "GapEventMediaBearerSetupCfm.h"
#include "GapEventMediaBearerSetupRej.h"

namespace tsc
{
namespace sgw
{

using common::EventData;

/**
 * Base class for GAP states
 */
class GapStateBase : public common::StateBase
{
public:

	/**
	 * Handle specified event for the specified generator.
	 * When the event is handled by state it should be deleted
	 *
	 * \param generator the generator for which the event occurred
	 * \param event the event to handle
	 */
    virtual
	void handleEvent(common::Generator*  generator,
	                 common::EventData*& event);

	/**
     * Checks if transmission to MGW associated with this generator
     * is possible in this state
     */
    virtual bool txEnabled() const;

protected:
	/**
	 * Creates new UAP state with specified name
	 * \param name the name of state
	 */
	GapStateBase(const char* name);

	virtual ~GapStateBase();

	virtual void handleEventGapConnectionInd(
	        GapGenerator* gapGen,
	        GapEventConnectionInd* event,
	        EventData*& eventData);

	virtual void handleEventGapT823Expired(
	        GapGenerator* gapGen,
	        GapEventT823Expired* event,
            EventData*& eventData);

    virtual void handleEventGapT8221Expired(
            GapGenerator* gapGen,
            GapEventT8221Expired* event,
            EventData*& eventData);

    virtual void handleEventGapEchoResponse(
            GapGenerator* gapGen,
            GapEventEchoResp* event,
            EventData*& eventData);

    virtual void handleEventGapMediaTransmissionFinishedInd(
            GapGenerator* gapGen,
            GapEventMediaTransmissionFinishedInd* event,
            EventData*& eventData);

    virtual void handleEventGapMediaBearerSetupCfm(
            GapGenerator* gapGen,
            GapEventMediaBearerSetupCfm* event,
            EventData*& eventData);

    virtual void handleEventGapMediaBearerSetupRej(
            GapGenerator* gapGen,
            GapEventMediaBearerSetupRej* event,
            EventData*& eventData);
};

} // namespace sgw
} // namespace tsc

#endif // SGW_GAP_STATE_BASE_H
